//
//  LFZMainBar.swift
//  Swift微博
//
//  Created by MagicalStar Pro on 15/12/29.
//  Copyright © 2015年 liang. All rights reserved.
//

import UIKit

class LFZMainBar: UITabBarController ,LFZTabItemDelegate{
    
    lazy var ControllerArray : [NSObject]? = {
    
        var array = [
            ["Normal":"tabbar_home","Selected":"tabbar_home_highlighted","title":"首页"],

            ["Normal":"tabbar_message_center","Selected":"tabbar_message_center_highlighted","title":"消息"],

            ["Normal":"tabbar_discover","Selected":"tabbar_discover_highlighted","title":"发现"],

            ["Normal":"tabbar_profile","Selected":"tabbar_profile_highlighted","title":"我"]

                        ]
    
        return array
    }()
    
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
        LFZMainBarAddSubViewController()
        
        let item =  LFZTabItem()
        
        item.delegaate = self
        
        for view in tabBar.subviews {
            
            view.removeFromSuperview()
        }
        
        tabBar.addSubview(item)
        
        item.frame = tabBar.bounds
        
        item.addSubviewWithImageArray(ControllerArray!)

    }

    func LFZMainBarAddSubViewController() {
        
        let home = LFZHomeTabVc()
        
        let navOne = LFZMainNavc(rootViewController : home)

        let Massage = LFZMassageTabVc()
        
        let navTwo = LFZMainNavc(rootViewController : Massage)
        
        let discoverVc = LFZDiscoverTabVc()
        
        let navThree = LFZMainNavc(rootViewController : discoverVc)
        
        let me = LFZMeTabVc()
        
        let navFour = LFZMainNavc(rootViewController: me)
        
        viewControllers = [navOne,navTwo,navThree,navFour]

        
    }
    
    func LFZTabItemWithButton(button: UIButton)
    {
        selectedIndex = button.tag
        
    }
    
}

extension LFZMainBar {
    
    
}
